package edu.hubu.adapter;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Context;
import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private List<String> list;
    private RecyclerView recyclerView;
    private RecyclerView.Adapter adapter;
    private Context context;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        context = this;
        // bind view
        recyclerView = findViewById(R.id.RecycleView);
        // set data
        list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add("第" + (i + 1) + "个列表项");
        }

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
        recyclerView.setLayoutManager(linearLayoutManager);

        // create adapter
        adapter = new MyAdapter(list);
        recyclerView.setAdapter(adapter);

    }
}